import 'package:package_info_plus/package_info_plus.dart';

import '../constant/config_constant.dart';
//
//packge info 辅助类
//
class PackageInfoHelper {

  static PackageInfo ? _info;

  ///需要在调用 SharedPreferences 前，调用此方法
  static Future<PackageInfo> getPackageInfo() async {
    if (_info != null) {
      return Future.value(_info);
    }

    _info = await PackageInfo.fromPlatform();
    init();
    return Future.value(_info);
  }

  static void init() {
    appName = _info!.appName;
    packageName = _info!.packageName;
    appVersion = _info!.version;
    buildNumber = _info!.buildNumber;
  }
}